<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <title>微金商城-登录</title>
    <link href="__PUBLIC__/Dt/image/favicon.ico" rel="icon" type="image/x-icon"/>
    <!--bootstrap-css-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Dt/lib/bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Dt/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Dt/css/login.css"/>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="__PUBLIC__/Dt/lib/html5shiv/html5shiv.min.js" ></script>
    <script type="text/javascript" src="__PUBLIC__/Dt/lib/html5shiv/html5shiv-printshiv.min.js" ></script>
    <![endif]-->
    <script type="text/javascript" src="__PUBLIC__/Dt/js/jquery-1.9.1.min.js" ></script>
    <script src="__PUBLIC__/Dt/js/jquery.cookie.js" type="text/javascript"></script>

    <script type="text/javascript" src="__PUBLIC__/Dt/Home/login.js" ></script>
    <script type="text/javascript" src="__PUBLIC__/Dt/lib/bootstrap/js/bootstrap.min.js" ></script>
    <script src="__PUBLIC__/Dt/js/index.js"></script>
</head>
<body>
<div class="tg hidden-xs">
    <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1967049675&site=qq&menu=yes">
        <img border="0" src="__PUBLIC__/Dt/image/qq.png" alt="点击这里给我发消息" title="点击这里给我发消息"/>
    </a>
</div>
<div class="login_logo hidden-xs">
    <img src="__PUBLIC__/Dt/image/login_logo.png"/>
</div>
<div class="login_box container">
		<div class="visible-xs-block moblie_logo">
			<img src="__PUBLIC__/Dt/image/mobile-logo.png"/>
		</div>
    <form action="/home/index/dologin" name='form' id='form' method='post' method="post" class="form-horizontal">
        <div class="row" class="dl-box" id="login">
            <div class="col-lg-12">
                <div class="form-group">
                    <span class="sp_user"></span>
                    <input type="text" class="form-control p_text" placeholder="输入账号" name="username" id="username" value="{$username}" >
                </div>
                <div class="form-group">
                    <span class="sp_pasw"></span>
                    <input type="password" class="form-control p_text" placeholder="输入密码" name="password" id="password" >
                </div>
                <div class="form-group">
                    <span class="sp_yzm"></span>
                    <input type="text" class="form-control p_text yzm" placeholder="输入验证码" name="verify" id="verify" value="{$code}">
                    <p class="yzm_img" id="captcha-container"><img  width="120"  style="cursor: hand;margin-right:14px; cursor:pointer;"  height="50" alt="验证码" src="{:U('home/index/verify',array())}" title="点击刷新"></p>
                </div>
                <div class="form-group clearfix" >
                    <label class="pull-left" ><input id="remenber" name="remenber" type="checkbox" value="1" class="chebox" /> 记住密码 </label>
                    <a href="javascript:;" class="pull-right wjmm">忘记密码?</a>
                </div>
                <div class="">
                    <input type="submit" class="btn btn-primary btn-lg btn-block" value="登录" onclick="return checkuser();"/>
                </div>
            </div>
        </div>
        <div class="row zhmm" style="display: none;"  id="getpassword">
        	<div class="h2 text-center">找回密码</div>
            <div class="col-lg-12" id="one">
                <div class="form-group">
                    <label class="col-sm-4 control-label">输入会员帐户</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control"  id="uname" name="uname"  placeholder="请输入会员帐户">
                    </div>
                </div>
			  <div class="form-group">
			    <label class="col-sm-4 control-label">输入手机号</label>
			    <div class="col-sm-8">
			      <input type="text" class="form-control" id="mobile" name="mobile"  placeholder="请输入手机号码">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="inputPassword3" class="col-sm-4 control-label">输入验证码</label>
			    <div class="col-sm-8">
			      <input type="password" class="form-control" name="mobile_code" id="mobile_code" placeholder="请输入验证码">
			      <div style="position: absolute;right: 15px;top: 0;">
                      <input id="zphone" name="zphone" type="button" value=" 获取手机验证码 " onClick="get_mobile_code();" class="btn btn-danger">
                  </div>
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="inputPassword3" class="col-sm-4 control-label"></label>
			    <div class="col-sm-8">
			      <button type="button" class="btn btn-success" onclick="GetNext();">下一步</button>
			      <button type="button" class="btn btn-danger qxzh">取消</button>
			    </div>
			  </div>
           </div>
        	<div style="display: none;" id="two">
        		<div class="col-lg-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">会员帐户</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" id="uname1" readonly >
                        </div>
                    </div>
				  <div class="form-group">
				    <label class="col-sm-4 control-label">输入新密码</label>
				    <div class="col-sm-8">
				      <input type="password" class="form-control" id="newpwd" name="newpwd" placeholder="输入新密码">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="inputPassword3" class="col-sm-4 control-label">确认新密码</label>
				    <div class="col-sm-8">
				      <input type="password" class="form-control" id="renewpwd" name="renewpwd"  placeholder="再次输入新密码">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="inputPassword3" class="col-sm-4 control-label"></label>
				    <div class="col-sm-8">
				      <button type="button" class="btn btn-success"  onclick="editpwd();">确认</button>
				    </div>
				  </div>
				</div>
        	</div>
       </div>
    </form>


</div>
<div style="width:100%;text-align: center;"><a href="http://www.beian.gov.cn">备案号：豫ICP备17005618号</a></div>
<div style="display: none;">
<script src="https://s11.cnzz.com/z_stat.php?id=1261354362&web_id=1261354362" language="JavaScript"></script>
</div>
</body>
</html>

<script>


    $(document).ready(function () {
        if ($.cookie("rmbUser") == "true") {
            $("#remenber").prop("checked", true);
            $("#username").val($.cookie("username"));
            $("#password").val($.cookie("password"));
        }

        tool();

    });

    function tool(){
        $(".wangji").click(function(){
            $('.find_box').show();
        });
        $(".close").click(function(){
            $('.find_box').hide();
        })
    }



    //记住用户名密码
    function Save() {
        if ($("#remenber").prop("checked")) {
            var str_username = $("#username").val();
            var str_password = $("#password").val();
            $.cookie("rmbUser", "true", { expires: 7 }); //存储一个带7天期限的cookie
            $.cookie("username", str_username, { expires: 7 });
            $.cookie("password", str_password, { expires: 7 });

        }
        else {
            $.cookie("rmbUser", "false", { expire: -1 });
            $.cookie("username", "", { expires: -1 });
            $.cookie("password", "", { expires: -1 });
        }
    };

    var loginuser=0;//是否已经登录，1是 0否
    function checkuser()
    {


        if($.trim($("#username").val())=="")
        {
            alert("请输入会员帐号！");
            $("#username").focus();
            return false;
        }





        var reg = /^[0-9a-zA-Z\u4e00-\u9fa5_]{1,16}$/;
        if(!reg.test($.trim($('#username').val())))
        {
            alert('会员帐户由1-16位汉字、字母、数字、下划线组成！');
            $('#username').focus();
            return false;
        }
        if($.trim($("#password").val())=="")
        {
            alert("请输入会员密码！");
            $("#password").focus();
            return false;
        }
        if($.trim($("#verify").val())=="")
        {
            alert("请输入验证码！");
            $("#verify").focus();
            return false;
        }

        var username,password,verify;
        username=$.trim($('#username').val());
        password=$.trim($('#password').val());
        verify=$.trim($('#verify').val());



        $.ajax({
            type: "POST",
            url: "/home/index/dologinajax",
            data: {'username':username,'password':password,'verify':verify,'login',loginuser},
            async:false,
            //dataType: "json",
            success: function(data){

                if(data==1)
                {
                    location.href='/user/';
                }
                if(data==2)
                {
                    alert('会员帐户或者密码不对，请重新输入！');
                    $('#username').focus();
                    return false;
                }

                if(data==3)
                {
                    alert('帐户已经被冻结，如有疑问请联系客服，谢谢！');
                    $('#verify').focus();
                    return false;
                }

                if(data==4)
                {
                    alert('帐户还没有开通，请联系推荐人开通后再登录，谢谢！');
                    $('#verify').focus();
                    return false;
                }

                if(data==5)
                {
                    alert('验证码不正确，请重新输入！');
                    $('#verify').focus();
                    var captcha_img = $('#captcha-container').find('img');
                    captcha_img.prop("src", '/home/index/verify.html?'+Math.random());


                    return false;
                }

                if(data==6) {
                    if (confirm('用户已经在其它设备登录，是否重新登录？'))
                    {
                         login=1;
                         checkuser();
                    }
                }

            }
        })


       return false;
        //Save();//记住密码
        // $("#form").submit();
    }



    var captcha_img = $('#captcha-container').find('img')
    var verifyimg = captcha_img.attr("src");
    captcha_img.attr('title', '点击刷新');
    captcha_img.click(function(){
        if( verifyimg.indexOf('?')>0){
            $(this).attr("src", verifyimg+'&random='+Math.random());
        }else{
            $(this).attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
        }
    });

    //获取手机验证码
    function get_mobile_code(){

        if ($.trim($('#uname').val()) == '')
        {
            alert('请先输入会员帐号');
            $('#uname').focus();
            return false;

        }
        if ($.trim($('#mobile').val()) == '')
        {
            alert('请先输入手机号码');
            $('#mobile').focus();
            return false;

        }
        var reg = /^1[3-9][0-9]\d{4,8}$/;
        if(!reg.test($.trim($('#mobile').val())))
        {
            alert("手机号码格式不对！");
            $('#mobile').focus();
            return false;
        }




        $.post('/home/index/sms', {uname:$.trim($('#uname').val()),mobile:jQuery.trim($('#mobile').val()),send_code:'{$Think.session.send_code}','template':'394713' }, function(msg) {
            //alert(jQuery.trim(unescape(msg)));
            if(msg==1)
            {
                alert('会员帐号不存在，请重新输入会员帐号！');
                $('#uname').focus();
                return;
            }
            if(msg==2)
            {
                alert('手机号码不能为空！');
                $('#mobile').focus();
                return;
            }
            if(msg==5)
            {
                alert('会员帐户没有绑定手机！');
                $('#mobile').focus();
                return;
            }
            if(msg==6)
            {
                alert('输入手机与会员绑定手机不一致！');
                $('#mobile').focus();
                return;
            }
            if(msg==3)
            {
                alert('请求超时，请刷新页面后重试！');
                return;
            }

            //alert(jQuery.trim(unescape(msg)));
            //return;

            if(msg==7){
                alert('同一手机号验证码短信发送超出5条！');
                $('#mobile').focus();
                return;
            }
            if(msg==4){
                alert('手机验证码已经发送，请注意查收！');
                RemainTime();
            }


        });
    };
    var iTime = 59;
    var Account;
    function RemainTime(){
        document.getElementById('zphone').disabled = true;
        var iSecond,sSecond="",sTime="";
        if (iTime >= 0){
            iSecond = parseInt(iTime%60);
            iMinute = parseInt(iTime/60)
            if (iSecond >= 0){
                if(iMinute>0){
                    sSecond = iMinute + "分" + iSecond + "秒";
                }else{
                    sSecond = iSecond + "秒";
                }
            }
            sTime=sSecond;
            if(iTime==0){
                clearTimeout(Account);
                sTime='获取手机验证码';
                iTime = 59;
                document.getElementById('zphone').disabled = false;
            }else{
                Account = setTimeout("RemainTime()",1000);
                iTime=iTime-1;
            }
        }else{
            sTime='没有倒计时';
        }
        document.getElementById('zphone').value = sTime;
    }
    //下一步
    var GetNext=function()
    {
        if ($.trim($('#uname').val()) == '')
        {
            alert('请先输入会员帐号');
            $('#uname').focus();
            return false;

        }
        if ($.trim($('#mobile').val()) == '')
        {
            alert('请先输入手机号码');
            $('#mobile').focus();
            return false;

        }
        var reg = /^1[3-9][0-9]\d{4,8}$/;
        if(!reg.test($.trim($('#mobile').val())))
        {
            alert("手机号码格式不对！");
            $('#mobile').focus();
            return false;
        }
        if ($.trim($('#mobile_code').val()) == '')
        {
            alert('请先输入手机验证码！');
            $('#mobile_code').focus();
            return false;

        }


        $.ajax({
            type: "POST",
            url: "/home/index/dosms",
            data: {
                'uname': $.trim($('#uname').val()),
                'mobile': $.trim($('#mobile').val()),
                'mobile_code': $.trim($('#mobile_code').val()),
            },
            async: true,
            success: function (msg) {
                if(msg==1)
                {
                    alert('会员帐号不存在，请重新输入会员帐号！');
                    $('#uname').focus();
                    return;
                }
                if(msg==2)
                {
                    alert('会员帐户没有绑定手机号码！');
                    $('#mobile').focus();
                    return;
                }
                if(msg==3)
                {
                    alert('输入手机与绑定号不符！');
                    $('#mobile').focus();
                    return;
                }
                if(msg==4)
                {
                    alert('输入验证码不正确！');
                    $('#mobile_code').focus();
                    return;
                }
                $('#one').css('display','none');
                $('#two').css('display','');
                $('#uname1').val($('#uname').val());

                //$('#resetpwd').css('display','block');
                //$('#getmobile').css('display','none');
               // $('#getpwd').css('display','block');
            }
        });

    }
    //修改密码
    var editpwd=function()
    {
        if ($.trim($('#newpwd').val()) == '')
        {
            alert('请先输入会员新密码');
            $('#newpwd').focus();
            return false;

        }
        if($.trim($('#newpwd').val()).length<6)
        {
            alert("新密码不能小于6位数！");
            $('#newpwd').focus();
            return false;
        }

        if ($.trim($('#renewpwd').val()) == '')
        {
            alert('请先输入会员确认新密码');
            $('#newpwd').focus();
            return false;

        }
        if ($.trim($('#renewpwd').val()) != $.trim($('#newpwd').val()))
        {
            alert('新密码与确认新密码不一致，请重新输入！');
            $('#renewpwd').focus();
            return false;

        }


        $.ajax({
            type: "POST",
            url: "/home/index/resetpwd",
            data: {
                'uname': $.trim($('#uname').val()),
                'mobile': $.trim($('#mobile').val()),
                'mobile_code': $.trim($('#mobile_code').val()),
                'newpwd': $.trim($('#newpwd').val()),
            },
            async: true,
            success: function (msg) {
                if(msg==1)
                {
                    alert('会员帐号不存在，请重新输入会员帐号！');
                    $('#setpwd').css('display','block');
                    $('#resetpwd').css('display','none');
                    $('#getmobile').css('display','block');
                    $('#getpwd').css('display','none');
                    $('#uname').focus();
                    return;
                }
                if(msg==2)
                {
                    alert('会员帐户没有绑定手机号码！');
                    $('#setpwd').css('display','block');
                    $('#resetpwd').css('display','none');
                    $('#getmobile').css('display','block');
                    $('#getpwd').css('display','none');
                    $('#mobile').focus();
                    return;
                }
                if(msg==3)
                {
                    alert('输入手机与绑定号不符！');
                    $('#setpwd').css('display','block');
                    $('#resetpwd').css('display','none');
                    $('#getmobile').css('display','block');
                    $('#getpwd').css('display','none');
                    $('#mobile').focus();
                    return;
                }
                if(msg==4)
                {
                    alert('输入验证码不正确！');
                    $('#setpwd').css('display','block');
                    $('#resetpwd').css('display','none');
                    $('#getmobile').css('display','block');
                    $('#getpwd').css('display','none');
                    $('#mobile_code').focus();
                    return;
                }
                if(msg=='success')
                {
                    alert('重置密码成功，请用新密码登录！');
                    $("#login").show();
                    $("#getpassword").hide();

                }
            }
        })
    }
</script>